layui.use('element', function(){
    var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
});
function ckeck_ok(order_ids) {//确认订单
    $.ajax({
        url: "setisok.do",
        type: "POST",
        data: {order_id: order_ids},
        async: false,
        success: function () {
            window.location.href = "admin.jsp";
        },
        error:function () {
            alert("操作失败");
        }
    })
}
function allorders() {//查看所有订单
    $.ajax({
        url: "allorders.do",
        type: "POST",
        success: function () {
            window.location.href = "admin.jsp";
        },
        error:function () {
            alert("操作失败");
        }
    })
}
function isokorders() {//查看确认订单
    $.ajax({
        url: "isokorders.do",
        type: "POST",
        success: function () {
            window.location.href = "admin.jsp";
        },
        error:function () {
            alert("操作失败");
        }
    })
}
function unisokorders() {//查看未确认订单
    $.ajax({
        url: "unisokorders.do",
        type: "POST",
        success: function () {
            window.location.href = "admin.jsp";
        }
    })
}
function goodshow(num) {//商品显示
    $.ajax({
        url: "goodshow.do",
        type: "POST",
        async:false,
        data:{num:num},
    });
    window.location.href = "admin_food.jsp";
}
function userset() {//用户管理
    $.ajax({
        url: "userset.do",
        type: "POST",
        async:false,
    });
    window.location.href = "admin_user.jsp";
}
function up_order_form(thisid) {//更新订单
    var tempform="up_oder_form_"+thisid;
    var tempaname="name_"+thisid;
    var tempaddr="address_"+thisid;
    var temptel="tel_"+thisid;
    var name=$("#"+tempaname).val();
    var address=$("#"+tempaddr).val();
    var tel=$("#"+temptel).val();
    if(name==''||name==null)
        alert("请输入姓名");
    else if(address==''||address==null)
        alert("请输入地址");
    else if(tel==''||tel==null)
        alert("请输入电话");
    else
        $("#"+tempform).submit();
}
function up_goods_form(thisid) {//更新商品
    var tempform="up_goods_form_"+thisid;
    var tempaname="name_"+thisid;
    var tempprice="price_"+thisid;
    var name=$("#"+tempaname).val();
    var price=$("#"+tempprice).val();
    if(name==''||name==null)
        alert("请输入商品名称");
    else if(price==''||price==null)
        alert("请输入商品价格");
    else
        $("#"+tempform).submit();
}
function ckeck_updataend() {
    alert("订单已确认，无法修改!");
}
function ckeck_del(order_id){//删除订单
    var con=confirm("你确认要删除该数据吗？");
    if(con==true){//点击了确认
        $.ajax({
            url:"delete_order.do",
            type:"POST",
            data:{order_id:order_id},
            async:false,
            success:function () {
                window.location.href="admin.jsp";
            },
            error:function () {
                alert("操作失败");
            }
        })
    }
}
function ckeck_goods_del(goods_id){//删除商品
    var con=confirm("你确认要删除该数据吗？");
    if(con==true){//点击了确认
        var goods_url=document.getElementById("goods_url_"+goods_id).value;
        $.ajax({
            url:"delete_goods.do",
            type:"POST",
            data:{goods_id:goods_id,goods_url:goods_url},
            async:false,
            success:function () {
                window.location.href="admin_food.jsp";
            },
            error:function () {
                alert("操作失败");
            }
        })
    }
}
function ckeck_user_del(user_id){//删除用户
    if(user_id==1){
        alert("管理员用户不能删除!!!");
        return;
    }
    var con=confirm("你确认要删除该数据吗？");
    if(con==true){//点击了确认
        $.ajax({
            url:"delete_user.do",
            type:"POST",
            data:{user_id:user_id},
            async:false,
            success:function () {
                window.location.href="admin_user.jsp";
            },
            error:function () {
                alert("操作失败");
            }
        })
    }
}
$("#out").click(function () {//退出操作
    $.ajax({
        url:"exit.do",
        type:"POST",
    })
})
layui.use('element', function(){
    var element = layui.element;
});
layui.use(['carousel', 'form'], function(){
    var carousel = layui.carousel
        ,form = layui.form;
    //图片轮播
    carousel.render({
        elem: '#heder01'
        ,width: 'margin: 0 auto'
        ,height: '440px'
        ,interval: 5000
    });
});